/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.jastrzab.core;

import android.content.Context;
import android.graphics.SurfaceTexture;
import android.hardware.Camera.Parameters;
import android.opengl.GLES20;
import android.os.Build;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import java.util.List;

/**
 *
 * @author Jastrzab
 */
public final class CameraImplements implements CameraContant {

	public static SurfaceTexture getSurfaceTexture() {
		int[] textures = new int[1];
		GLES20.glGenTextures(1, textures, 0);
		GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, textures[0]);
		return new SurfaceTexture(textures[0]);
	}

	public static SurfaceHolder getSurfaceHolder(Context context) {
		SurfaceHolder surface = new SurfaceView(context).getHolder();
		surface.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
		return surface;
	}
	
	public static boolean isSurfaceTexture() {
		return Build.VERSION.SDK_INT >= 11;
	}

	public static String getLightSuported(Parameters paramter) {
		List<String> supportedFlashModes = paramter.getSupportedFlashModes();
		if (supportedFlashModes != null) {
			for (String string : supportedFlashModes) {
				if (string.equals(Parameters.FLASH_MODE_TORCH)) {
					return Parameters.FLASH_MODE_TORCH;
				}
			}
		}
		return Parameters.FLASH_MODE_OFF;
	}

}
